<template>
  <div class="coupon">
    <h5>
      <span>优惠券审核</span>
      <span class="add my-background" style="margin: 0 20px" @click="addCoupon">添加优惠券</span>
    </h5>
    <div class="coupon-header">
      <div class="search-inp">
        <div class="item">
          <span class="item-text">发行者姓名</span>
          <input type="text" v-model="issueName" placeholder="请输入发行者姓名" />
        </div>
        <div class="item">
          <span class="item-text">面值类型</span>
          <el-select v-model="faceType" placeholder="请选择">
            <el-option  v-for="item in searchoptions1"  :key="item.id"  :label="item.name"  :value="item.id"></el-option>
          </el-select>
        </div>
        <div class="item">
          <span class="item-text">业务类型</span>
          <el-select v-model="busKey" placeholder="请选择">
            <el-option  v-for="item in searchoptions2"  :key="item.id"  :label="item.name"  :value="item.id"></el-option>
          </el-select>
        </div>
        <el-button type="primary" @click="search">搜索</el-button>
        <el-button type="info" @click="empty">清空</el-button>
      </div>
    </div>
    <div class="tabs">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="待审核" name="first">
          <div class="table">
            <el-table  ref="multipleTable" :data="tableData"  tooltip-effect="dark"  style="width: 100%">
              <el-table-column type="selection" v-if="isShowCheck"></el-table-column>
              <el-table-column prop="issueName" label="发行者姓名"></el-table-column>
              <el-table-column prop="couponName" label="优惠券名称"></el-table-column>
              <el-table-column label="面值类型">
                <template slot-scope="scope">
                    <span v-if="scope.row.faceType==1" type="text">现金券</span>
                    <span v-else-if="scope.row.faceType==2" type="text">折扣</span>
                    <span v-else-if="scope.row.faceType==3" type="text">满减</span>
                </template>
              </el-table-column>
              <el-table-column label="业务类型">
                <template slot-scope="scope">
                    <span v-if="scope.row.busKey==1" type="text">商超</span>
                    <span v-else-if="scope.row.busKey==2" type="text">酒店</span>
                    <span v-else-if="scope.row.busKey==3" type="text">直播带货</span>
                    <span v-else-if="scope.row.busKey==4" type="text">社区配餐</span>
                    <span v-else-if="scope.row.busKey==5" type="text">购买直播礼物</span>
                    <span v-else type="text">推广奖励</span>
                </template>
              </el-table-column>
              <el-table-column label="创建时间">
                <template slot-scope="scope">
                    <span type="text">{{format(scope.row.createTime)}}</span>
                </template>
              </el-table-column>
              <el-table-column label="操作" width="200">
                <template slot-scope="scope">
                    <el-button @click="examine(scope.row)" type="text">审核</el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-tab-pane>
        <el-tab-pane label="已审核" name="second">
          <div class="table">
            <el-table  ref="multipleTable" :data="tableData"  tooltip-effect="dark"  style="width: 100%" >
              <el-table-column type="selection" v-if="isShowCheck"></el-table-column>
              <el-table-column prop="issueName" label="发行者姓名"></el-table-column>
              <el-table-column prop="couponName" label="优惠券名称"></el-table-column>
              <el-table-column label="面值类型">
                <template slot-scope="scope">
                    <span v-if="scope.row.faceType==1" type="text">现金券</span>
                    <span v-else-if="scope.row.faceType==2" type="text">折扣</span>
                    <span v-else-if="scope.row.faceType==3" type="text">满减</span>
                </template>
              </el-table-column>
              <el-table-column label="业务类型">
                <template slot-scope="scope">
                    <span v-if="scope.row.busKey==1" type="text">商超</span>
                    <span v-else-if="scope.row.busKey==2" type="text">酒店</span>
                    <span v-else-if="scope.row.busKey==3" type="text">直播带货</span>
                    <span v-else-if="scope.row.busKey==4" type="text">社区配餐</span>
                    <span v-else-if="scope.row.busKey==5" type="text">购买直播礼物</span>
                    <span v-else type="text">推广奖励</span>
                </template>
              </el-table-column>
              <el-table-column label="创建时间">
                <template slot-scope="scope">
                    <span type="text">{{format(scope.row.createTime)}}</span>
                </template>
              </el-table-column>
              <el-table-column label="状态">
                <template slot-scope="scope">
                    <span type="text">{{scope.row.isEnable==1?'停用':'启用'}}</span>
                </template>
              </el-table-column>
              <el-table-column label="操作" width="200">
                <template slot-scope="scope">
                    <el-button @click="stopexamine(scope.row)" type="text">{{scope.row.isEnable==0?'停用':'启用'}}</el-button>
                    <el-button @click="viewClick(scope.row,1)" type="text">修改</el-button>
                    <el-button @click="viewClick(scope.row,2)" type="text">查看</el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-tab-pane>
      </el-tabs>
      <el-pagination @size-change="handleSizeChange"  @current-change="handleCurrentChange"  :current-page="currentPage"  :page-sizes="[5, 10, 15, 20]"  :page-size="5"  layout="total, sizes, prev, pager, next, jumper"  :total=total></el-pagination>
    </div>
     <!-- 弹窗 -->
    <div class="mask" v-show="masknum">
      <div class="content">
        <p style="font-size:22px">优惠券审核</p>
        <div class="item-content">
          <div class="item-left">
            <div class="item">
              <span>发行者姓名：</span>
              <span>{{examineData.issueName}}</span>
            </div>
            <div class="item">
              <span>面值类型：</span>
              <span v-if="examineData.faceType==1">现金券</span>
              <span v-else-if="examineData.faceType==2">折扣</span>
              <span v-else>满减</span>
            </div>
            <div class="item">
              <span>业务类型：</span>
              <span v-if="examineData.busKey==1">商超</span>
              <span v-else-if="examineData.busKey==2">酒店</span>
              <span v-else-if="examineData.busKey==3">直播带货</span>
              <span v-else-if="examineData.busKey==4">社区配餐</span>
              <span v-else-if="examineData.busKey==5">购买直播礼物</span>
              <span v-else-if="examineData.busKey==6">推广奖励</span>
            </div>
              <div class="item">
              <span>开始时间：</span>
              <span>{{format(examineData.startTime)}}</span>
            </div>
            <div class="item">
              <span>审批人：</span>
              <span>{{examineData.chkUser}}</span>
            </div>
          </div>
          <div class="item-right">
            <div class="item">
              <span>优惠券名称：</span>
              <span class="text-ellipsis" style="width:100px;">{{examineData.couponName}}</span>
            </div>
            <div class="item">
              <span>面值：</span>
              <span v-if="examineData.faceType==1">{{examineData.faceValue/100}}元</span>
              <span v-else-if="examineData.faceType==2">{{examineData.faceValue/10}}折</span>
              <span v-else-if="examineData.faceType==3">满{{examineData.faceValue.split(":")[0]*0.01}}元减{{examineData.faceValue.split(":")[1]*0.01}}元</span>
            </div>
            <div class="item">
              <span>发行数量：</span>
              <span>{{examineData.issueNum}}</span>
            </div>
            <div class="item">
              <span>结束时间：</span>
              <span>{{format(examineData.endTime)}}</span>
            </div>
            <div class="item">
              <span>使用范围：</span>
              <span v-if="examineData.applyLimits==0">全平台</span>
              <span v-else-if="examineData.applyLimits==1">商户</span>
              <span v-else-if="examineData.applyLimits==2">商品</span>
            </div>
          </div>
         
          <div class="my-top" style="margin-left:102px">
            <span>审核：</span>
            <template>
              <el-radio @change="radioChange" v-model="radioNum" label="1">通过</el-radio>
              <el-radio @change="radioChange" v-model="radioNum" label="2">未通过</el-radio>
            </template>
          </div>
          <div v-if="isShowRemark" class="remark my-top" style="margin-left:102px">
              <span>备注：</span>
              <textarea v-model="remarkData" name="" id="" cols="30" rows="3" resize:none></textarea>
          </div>
          <div class="my-top">
            <span class="my-btn" style="margin-left: 218px;margin-right: 20px;" @click="cancel">取消</span>
            <span class="my-btn my-background" @click="determine">确定</span>
          </div>
        </div>
      </div>
    </div>
    <div class="mask" v-show="masknum2">
      <div class="content">
        <p style="font-size:20px">添加优惠券</p>
        <div class="item-content">
          <div class="item-list">
            <span>
              <span style="color:red;">*</span>
              优惠券名称
            </span>
            <input type="text" maxlength="50"  v-model="addCouponData.couponName">
            <span style="color:#bbb;font-size:14px;padding-left:20px;">(50字以内)</span>
          </div>
          <div class="item-list">
            <span>
              <span style="color:red;">*</span>
              业务类型
            </span>
            <el-select v-model="addCouponData.busKey" placeholder="请选择">
              <el-option
                v-for="item in searchoptions2"
                :key="item.id"
                :label="item.name"
                :value="item.id">
              </el-option>
            </el-select>
          </div>
          <div class="item-list">
            <span>
              <span style="color:red;">*</span>
              优惠券类型
            </span>
            <el-select v-model="addCouponData.faceType" placeholder="请选择">
              <el-option
                v-for="item in addfaceType"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </div>
          <div class="item-list">
            <span>
              <span style="color:red;">*</span>
              使用范围
            </span>
            <el-select v-model="addCouponData.applyLimits" placeholder="请选择">
              <el-option
                v-for="item in addCouponLimits"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </div>
          <div class="item-list">
            <span>
              <span style="color:red;">*</span>
              发放数量
            </span>
            <input type="number" v-model="addCouponData.issueNum">
          </div>
          <div class="item-list" v-if="addCouponData.faceType">
            <span>
              <span style="color:red;">*</span>
              规则
            </span>
            <div class="list-input">
              <div v-if="addCouponData.faceType==3">
                满<input type="text" v-model="faceValue.num1">元，减
                <input type="text" v-model="faceValue.num2">元。
              </div>
              <div v-else-if="addCouponData.faceType==2">
                打<input type="text" v-model="faceValue.num1">折，最高减
                <input type="text" v-model="faceValue.num2">元。
              </div>
              <div v-else-if="addCouponData.faceType==1">
                无门槛，减<input type="text" v-model="faceValue.num1">元。
              </div>
            </div>
          </div>
          <div class="item-list">
            <span>
              <span style="color:red;">*</span>
              使用时间
            </span>
            <el-date-picker
              v-model="addCouponDatatime"
              type="daterange"
              value-format="timestamp"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期">
            </el-date-picker>
          </div>
        </div>
        <div class="mask-button">
          <el-button type="primary" plain @click="maskSubmit">确定</el-button>
          <el-button type="info" plain @click="maskCancel">取消</el-button>
        </div>
      </div>
    </div>
    <div class="mask" v-show="masknum3">
      <div class="content">
        <p style="font-size:20px">{{editNum==1?'修改':'查看'}}优惠券</p>
        <div class="item-content">
          <div class="item-list">
            <span>
              <span style="color:red;">*</span>
              优惠券名称
            </span>
            <span v-if="editNum==2">{{editData.couponName}}</span>
            <input v-if="editNum==1" type="text" maxlength="50"  v-model="editData.couponName">
            <span v-if="editNum==1" style="color:#bbb;font-size:14px;padding-left:20px;">(50字以内)</span>
          </div>
          <div class="item-list">
            <span>
              <span style="color:red;">*</span>
              业务类型
            </span>
            <div v-if="editNum==2">
              <span>{{editData.busKey}}</span>
            </div>
            <el-select v-else id="busKey" v-model="editData.busKey" placeholder="请选择">
              <el-option
                v-for="item in searchoptions2"
                :key="item.id"
                :label="item.name"
                :value="item.id">
              </el-option>
            </el-select>
          </div>
          <div class="item-list">
            <span>
              <span style="color:red;">*</span>
              优惠券类型
            </span>
            <div v-if="editNum==2">
              <span>{{editData.faceType}}</span>
            </div>
            <el-select v-else id="faceType" v-model="editData.faceType" placeholder="请选择">
              <el-option
                v-for="item in addfaceType"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </div>
          <div class="item-list">
            <span>
              <span style="color:red;">*</span>
              使用范围
            </span>
            <div v-if="editNum==2">
              <span>{{editData.applyLimits}}</span>
            </div>
            <el-select v-else id="applyLimits" v-model="editData.applyLimits" placeholder="请选择">
              <el-option
                v-for="item in addCouponLimits"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </div>
          <div class="item-list">
            <span>
              <span style="color:red;">*</span>
              发放数量
            </span>
            <span v-if="editNum==2">{{editData.issueNum}}</span>
            <input v-else type="number" v-model="editData.issueNum">
          </div>
          <div class="item-list" v-if="editData.faceType">
            <span>
              <span style="color:red;">*</span>
              规则
            </span>
            <div class="list-input">
              <div v-if="editData.faceType==3||editData.faceType=='满减券'">
                满<input v-if="editNum==1" type="text" v-model="faceValue.num1"> <span v-else>{{faceValue.num1}}</span> 元，减
                <input v-if="editNum==1" type="text" v-model="faceValue.num2"> <span v-else>{{faceValue.num2}}</span>元。
              </div>
              <div v-else-if="editData.faceType==2||editData.faceType=='折扣券'">
                打<input type="text" v-if="editNum==1" v-model="faceValue.num1"><span v-else>{{faceValue.num1}}</span>折，最高减
                <input type="text" v-if="editNum==1" v-model="faceValue.num2"><span v-else>{{faceValue.num2}}</span>元。
              </div>
              <div v-else-if="editData.faceType==1||editData.faceType=='现金券'">
                无门槛，减<input type="text" v-if="editNum==1" v-model="faceValue.num1"><span v-else>{{faceValue.num1}}</span>元。
              </div>
            </div>
          </div>
          <div class="item-list">
            <span>
              <span style="color:red;">*</span>
              使用时间
            </span>
            <el-date-picker
              v-if="editNum==1"
              v-model="addCouponDatatime"
              type="daterange"
              value-format="timestamp"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期">
            </el-date-picker>
            <el-date-picker
              v-else
              disabled
              v-model="addCouponDatatime"
              type="daterange"
              value-format="timestamp"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期">
            </el-date-picker>
          </div>
        </div>
        <div class="mask-button">
          <el-button v-if="editNum==1" type="primary" plain @click="mask3Submit">确定</el-button>
          <el-button v-if="editNum==1" type="info" plain @click="mask3Cancel">取消</el-button>
          <el-button v-if="editNum==2" type="info" plain @click="mask3Cancel">返回</el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      baseurl:'',
      isShowRemark:false,
      batchDelete:'批量删除',
      examineData:'',
      isShowCheck:false,//最左侧的多选框是否显示
      radioNum: '1',//单选框
      remarkData:'',
      masknum:false,//弹窗
      masknum2:false,//添加优惠券
      masknum3:false,//修改-查看
      editNum:1,//修改-1，查看-2
      editData:'',//修改-查看数据
      addCouponData:{
        issueName:'',//发行者姓名
        couponName:'',//名称
        busKey:'',//业务类型
        faceType:'',//类型
        applyLimits:'',//使用范围 
        issueNum:'',//发放数量
        faceValue:'',//面值
        endTime:'',//结束时间
        startTime:'',//开始时间
      },
      faceValue:{
        num1:'',
        num2:''
      },
      addCouponDatatime:[],
      addfaceType: [
        {value: '1',label: '现金券'}, 
        {value: '2',label: '折扣券'}, 
        {value: '3',label: '满减券'}
      ],
      addCouponLimits:[
        {value: '0',label: '全平台'}, 
        {value: '1',label: '商户'}, 
        {value: '2',label: '商品'}
      ],
      isChk:0,
      tableData: [],
      activeName: 'first',
      issueName: "",//发行者姓名
      faceType: "",//面值类型
      busKey: "",//业务类型
      searchoptions1:[//面值类型
        {id:'1',name:'现金券'},
        {id:'2',name:'折扣'},
        {id:'3',name:'满减'},
      ],
      searchoptions2:[//业务类型
        {id:'1',name:'商超'},
        {id:'2',name:'酒店'},
        {id:'3',name:'直播带货'},
        {id:'4',name:'社区配餐'},
        {id:'5',name:'购买直播礼物'},
        {id:'6',name:'推广奖励'},
      ],
      //分页
      limit:5,
      page:1,
      total:0,
      currentPage: 1,
    };
  },
  mounted() {
    this.baseurl=this.$store.state.baseurl
    this.addCouponData.issueName = sessionStorage.getItem('uname')
    this.getCoupon()
  },
  methods: {
    //查看
    viewClick(row,editNum){
      this.faceValue={num1:'',num2:''}
      this.masknum3=true
      this.editNum=editNum
      this.editData=row
      if(this.editData.faceType==1){
        this.faceValue.num1=this.editData.faceValue*0.01
      console.log('faceValue',this.faceValue)
      }else if(this.editData.faceType==2){
        this.faceValue.num1=this.editData.faceValue*0.1
        this.faceValue.num2=this.editData.moreFaceValue
      console.log('faceValue',this.faceValue)
      }else{
        this.faceValue.num1=this.editData.faceValue.split(/[:：]/)[0]*0.01
        this.faceValue.num2=this.editData.faceValue.split(/[:：]/)[1]*0.01
      }
      this.searchoptions2.forEach(e=>{
        if(e.id==this.editData.busKey){
          this.editData.busKey=e.name
        }
      })
      this.addfaceType.forEach(e=>{
        if(e.value==this.editData.faceType){
          this.editData.faceType=e.label
        }
      })
      this.addCouponLimits.forEach(e=>{
        if(e.value==this.editData.applyLimits){
          this.editData.applyLimits=e.label
        }
      })
      this.addCouponDatatime=[new Date(this.editData.startTime*1000), new Date(this.editData.endTime*1000)]
      console.log(row)
    },
    //确定
    mask3Submit(){
      this.searchoptions2.forEach(e=>{
        if(e.name==this.editData.busKey){
          this.editData.busKey=e.id
        }
      })
      this.addfaceType.forEach(e=>{
        if(e.label==this.editData.faceType){
          this.editData.faceType=e.value
        }
      })
      this.addCouponLimits.forEach(e=>{
        if(e.label==this.editData.applyLimits){
          this.editData.applyLimits=e.value
        }
      })
      if(!this.editData.couponName){
        this.$message('优惠券名称不能为空');return
      }else if(!this.editData.busKey){
        this.$message('业务类型不能为空');return
      }else if(!this.editData.faceType){
        this.$message('优惠券类型不能为空');return
      }else if(this.editData.applyLimits!=0&&this.editData.applyLimits!=1&&this.editData.applyLimits!=2){
        this.$message('使用范围不能为空');return
      }else if(this.editData.issueNum<=0){
        this.$message('优惠券数量不能小于等于0');
        return
      }else if(this.addCouponDatatime.length<2){
        this.$message('使用时间不能为空');return
      }
      var agreementEntity=this.editData
      agreementEntity.endTime=this.addCouponDatatime[1]/1000
      agreementEntity.startTime=this.addCouponDatatime[0]/1000
      agreementEntity.applyLimits=agreementEntity.applyLimits*1
      if(agreementEntity.faceType==1){
        agreementEntity.faceValue=this.faceValue.num1*100
      }else if(agreementEntity.faceType==2){
        agreementEntity.faceValue=this.faceValue.num1
        agreementEntity.moreFaceValue=this.faceValue.num2
      }else{
        agreementEntity.faceValue=this.faceValue.num1*100+':'+this.faceValue.num2*100
      }
      this.axios({
            url:this.baseurl+'/coupon/create',
            method:'post',
            data:agreementEntity,
      }).then(res=>{
        if(res.data.code==200){
          this.$message('优惠券修改成功')
          this.mask3Cancel()
        }else{
          alert(res.data.errmsg)
        }
      })
    },
    //取消
    mask3Cancel(){
      this.masknum3=false
      this.editData=''
      this.faceValue={num1:'',num2:''}
      this.addCouponDatatime=[]
      this.getCoupon()
    },
    //添加优惠券
    addCoupon(){
      this.masknum2=true
    },
    //优惠券提交
    maskSubmit(){
      if(!this.addCouponData.couponName){
        this.$message('优惠券名称不能为空');return
      }else if(!this.addCouponData.busKey){
        this.$message('业务类型不能为空');return
      }else if(!this.addCouponData.faceType){
        this.$message('优惠券类型不能为空');return
      }else if(this.addCouponData.applyLimits!=0&&this.addCouponData.applyLimits!=1&&this.addCouponData.applyLimits!=2){
        this.$message('使用范围不能为空');return
      }else if(this.addCouponData.issueNum<=0){
        this.$message('优惠券数量不能小于等于0');
        return
      }else if(this.addCouponDatatime.length<2){
        this.$message('使用时间不能为空');return
      }
      var agreementEntity=this.addCouponData
      agreementEntity.endTime=this.addCouponDatatime[1]/1000
      agreementEntity.startTime=this.addCouponDatatime[0]/1000
      agreementEntity.applyLimits=agreementEntity.applyLimits*1
      if(agreementEntity.faceType==1){
        agreementEntity.faceValue=this.faceValue.num1*100
      }else if(agreementEntity.faceType==2){
        agreementEntity.faceValue=this.faceValue.num1*10
        agreementEntity.moreFaceValue=this.faceValue.num2
      }else{
        agreementEntity.faceValue=this.faceValue.num1*100+':'+this.faceValue.num2*100
      }
      this.axios({
            url:this.baseurl+'/coupon/create',
            method:'post',
            data:agreementEntity,
      }).then(res=>{
        if(res.data.code==200){
          this.$message('优惠券添加成功')
          this.maskCancel()
          this.getCoupon()
        }else{
          alert(res.data.errmsg)
        }
      })
    },
    //优惠券取消
    maskCancel(){
      this.masknum2=false
      this.addCouponData={
        couponName:'',//名称
        faceType:'',//类型
        applyLimits:'',//使用范围 
        issueNum:'',//发放数量
        faceValue:'',//面值
        endTime:'',//结束时间
        startTime:'',//开始时间
      }
      this.faceValue={num1:'',num2:''}
      this.addCouponDatatime=[]
    },
    //分页
    handleSizeChange(val) {
      this.limit=val
      this.getCoupon()
    },
    handleCurrentChange(val) {
      this.page=val
      this.getCoupon()
    },
    handleClick(tab, event) {
        console.log(tab, event);
    },
    //搜索
    search(){
      this.page=1
      this.limit=5
      this.getCoupon()
    },
    //清空
    empty(){
      this.isChk=0
      this.page=1
      this.limit=5
      this.busKey=''
      this.issueName=''
      this.faceType=''
      this.getCoupon()
    },
    //获取优惠券列表
    getCoupon(){
      var agreementEntity={
        "isChk":this.isChk,
        "limit":this.limit,
        "page":this.page
      }
      if(this.busKey){agreementEntity.busKey=this.busKey}
      if(this.issueName){agreementEntity.issueName=this.issueName}
      if(this.faceType){agreementEntity.faceType=this.faceType}
      this.axios({
        url:this.baseurl+'/coupon/list',
        method:'post',
        data:agreementEntity,
      }).then(res=>{
        if(res.data.code==200){
          this.tableData=res.data.data.list
          this.total=res.data.data.totalCount
        }else{
          alert(res.data.errmsg)
        }
      })
    },
    radioChange(lv){
      this.isShowRemark = (lv == '2');
    },
      // 审核
       examine(row){
         this.masknum=true
         this.examineData=row
       },
       //停用
       stopexamine(row){
         var isEnable=0
         if(row.isEnable==0){isEnable=1}
         var agreementEntity={
            "enable":isEnable,
            "cid":row.id
          }
          this.$confirm('是否停用改优惠券','提示',{
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(()=>{
            this.axios({
                url:this.baseurl+'/coupon/enable',
                method:'post',
                data:agreementEntity,
            }).then(()=>{
              this.$message({
                type: 'success',
                message: '已停用!'
              });
              this.getCoupon()
            })
          })
       },
      // 取消
      cancel(){
        this.masknum=false
        this.examineData=''
      },
      // 确定
      determine(){
        this.masknum=false
        var agreementEntity={
          "remarkData":this.remarkData,
          "isChk":this.radioNum,
          "cid":this.examineData.id
        }
        this.$confirm('是否提交该审核','提示',{
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(()=>{
          this.axios({
              url:this.baseurl+'/coupon/chkcoupon',
              method:'post',
              data:agreementEntity,
          }).then(()=>{
            this.$message({
              type: 'success',
              message: '审核成功!'
            });
            this.getCoupon()
          })
        })
      },
      //处理时间戳
      format(shijianchuo) {
          var time = new Date(shijianchuo*1000);
          var y = time.getFullYear();
          var m = time.getMonth() + 1;
          var d = time.getDate();
          var h = time.getHours();
          var f = time.getMinutes();
          var s = time.getSeconds();
          //想要什么格式可以自己改
          // return y + '-' + this.add0(m) + '-' + this.add0(d) +" "+ this.add0(h)+':'+this.add0(f)+':'+this.add0(s);
          return y + '-' + m + '-' + d +" "+ this.add0(h)+':'+this.add0(f);
      },
      //小于10的时候，前边加0（08：08：12）
      add0(m) {
          return m < 10 ? '0' + m : m
      },
  },
  watch: {
    activeName(){
      if(this.activeName=='first'){
        this.isChk=0
        this.page=1
        this.limit=5
        this.currentPage=1
        this.getCoupon()
      }else{
        this.isChk=1
        this.page=1
        this.limit=5
        this.currentPage=1
        this.getCoupon()
      }
    }
  },
};
</script>

<style scoped>
.coupon>h5{
    display: flex;
    justify-content: space-between;
}
.coupon>h5 .add{
    display: inline-block;
    font-size: 15px;
    text-align: center;
    border-radius: 3px;
    color: #fff;
    padding: 10px 12px;
}
.coupon-header {
  margin-top: 20px;
  display: flex;
  align-items: flex-start;
}
/* 搜索input框 */
.search-inp {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}
.search-inp .item {
  width: 330px;
}
.search-inp .item-text {
  width: 100px;
  text-align: right;
  display: inline-block;
  margin-right: 10px;
}
.tabs {
  padding-left: 20px;
}

/* 遮罩层 */
.mask{
    width: 100vw;
    height: 100vh;
    background: rgba(51, 51, 51, 0.692);
    position: fixed;
    z-index: 99;
    top: 0;
    left: 0;
}
.content{
  width: 700px;
  max-height: 90vh;
  overflow: auto;
  background: #FFFFFF;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);
  border-radius:3px;
  padding: 30px;
}
.item-content{
  margin-top: 10px;
}
.item-left,.item-right{
  display: inline-block;
  width: 47%;
}
.item-left .item :nth-child(1){
  width: 150px;
  text-align: right;
  display: inline-block;
  margin-right: 5px;
}
.item-right .item :nth-child(1){
  width: 150px;
  text-align: right;
  display: inline-block;
}
.item-right .item{
  display: flex;
  align-items: center;
}
.item span,.my-top{
  margin-top: 10px;
}
.remark{
  display: flex;
  align-items: flex-start;
}
/* 遮罩层2 */
.mask .item-list{
  display: flex;
  align-items: center;
  margin: 20px 0;
}
.mask .item-list>span{
  display: inline-block;
  width: 110px;
}
.mask .item-list .list-input input{
  width: 45px;
  height: 32px;
  margin: 0 10px;
}
.mask .item-list .list-input>div{
  margin-bottom: 18px;
  font-size: 15px;
}
.mask .mask-button{
  text-align: center;
}
</style>
<style>
.el-date-editor .el-range-separator{
  width: 10%!important;
}
</style>